package com.magic.gre.utils;


import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;

/**
 * Author: Lmoumou
 * Date: 2018-09-26 16:26
 * 文件名: PermissonUtils
 * 描述:
 */
public class PermissonUtils {

    /**
     * 本地读写权限
     */
    public static final String[] READ_WRITE = {Manifest.permission.READ_EXTERNAL_STORAGE,
            Manifest.permission.WRITE_EXTERNAL_STORAGE};

    /**
     * 拍照
     */
    public static final String[] PHOTOGRAPH = {Manifest.permission.READ_EXTERNAL_STORAGE,
            Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA};

    public static boolean check(Context context, String[] strings) {
        boolean result = true;
        PackageManager pm = context.getPackageManager();
        for (String s : strings) {
            boolean permission_readStorage = (PackageManager.PERMISSION_GRANTED ==
                    pm.checkPermission(s, context.getPackageName()));
            result = result && (PackageManager.PERMISSION_GRANTED == pm.checkPermission(s, context.getPackageName()));

        }
        return result;
    }

    /**
     * 定位
     */
    public static final String[] LOCAL = {Manifest.permission.ACCESS_COARSE_LOCATION,
            Manifest.permission.ACCESS_FINE_LOCATION,
            Manifest.permission.WRITE_EXTERNAL_STORAGE,
            Manifest.permission.READ_EXTERNAL_STORAGE,
            Manifest.permission.READ_PHONE_STATE};

    /**
     * 视频录制
     */
    public static final String[] VIDEO = {Manifest.permission.READ_EXTERNAL_STORAGE,
            Manifest.permission.WRITE_EXTERNAL_STORAGE,
            Manifest.permission.CAMERA,
            Manifest.permission.RECORD_AUDIO};

    /**
     * 音频
     */
    public static final String[] VOICE = {
            Manifest.permission.RECORD_AUDIO};
}
